<template>
  <div>

  </div>
</template>


<script>
import  request from '../../utils/request'

export default {
  name: 'auth-redirect',
  data() {
    return {
      fullscreenLoading: false,
      userId: sessionStorage.getItem("userid")?JSON.parse(sessionStorage.getItem("userid")):''
    }
  },
  created() {
     // this.userId = this.$route.query.userid
    console.log("$route:",this.$route)
    this.openFullScreen2()
    console.log("userId:",this.userId)
    if (this.userId) {
      this.authLogin()
    }
  },
  methods: {
    openFullScreen2() {
      const loading = this.$loading({
        lock: true,
        text: '登录成功，正在跳转...',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      setTimeout(() => {
        loading.close();
      }, 1000);
    },
    authLogin() {
      console.log(this.$route)
      console.log("dnakdkjadnka"+this.userId)
      // 根据UerId查询用户信息
      // let userId=sessionStorage.getItem("userid")
      // console.log("<===="+userId)
      request.get('/auth/login/' + this.userId).then( res => {

        const that = this

        /*   var captcha = new TencentCaptcha(
             RondomPass().toString(),
             function (res) {
               console.log(res)
               if (res.ret === 0) {*/


        that.$store.dispatch('user/login', this.loginForm).then((res) => {
          // if(res.role=='ROLE_USER'){

          that.$router.push('/front/home')
          this.$router.go(1)
          localStorage.setItem("user", JSON.stringify(res))
          localStorage.setItem("menus", JSON.stringify(res.menus))  // 存储用户信息到浏览器
        })

        })
      }
  }
}
</script>
